package com.idemon.springbootredis;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Repository;

import java.util.concurrent.TimeUnit;

@Repository
public class RedisDAO {
    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    public void put(String key,String value){
        stringRedisTemplate.opsForValue().set(key,value,5, TimeUnit.MINUTES);
    }

    public String get(String key){
        return stringRedisTemplate.opsForValue().get(key);
    }
}
